﻿using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;

namespace FySystem.Net.SimSocket
{
    internal class SimStateObjectBase
    {
        internal string ID { get; set; }

        internal const int BufferSize = 4096;

        internal byte[] buffer = new byte[BufferSize];

        /// <summary>
        /// 收到的数据
        /// </summary>
        internal List<byte> stream = new List<byte>();

        /// <summary>
        /// 是否已经完成了握手
        /// </summary>
        internal bool helloFlag = false;

        internal Socket workSocket { get; set; }

        /// <summary>
        /// 最后收到数据的时间
        /// </summary>
        internal DateTime lastReceivedTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 释放连接
        /// </summary>
        internal void Dispose()
        {
            try
            {
                if (workSocket != null)
                {
                    workSocket.Dispose();
                }
            }
            catch { }
        }
    }
}
